<template>
  <div class="pageWrapper">
    <common-header />
    <div class="content">
      <div class="card">
        <div class="card-content">
          <div class="title">
            {{ resultInfo.year }}年<span v-if="resultInfo.quarter">第{{ resultInfo.quarter }}季</span>度考核优秀等次名单
          </div>
          <div class="number-wrap">
            <div class="copy">{{ resultInfo.deptNameTree || resultInfo.unitName }}</div>
            <div class="number">共 {{ resultInfo.num || resultInfo.count }} 人</div>
          </div>
        </div>
      </div>
      <div class="list">
        <div class="list-item" v-for="item in list" :key="item.id">
          <!-- <img src="" alt=""> -->
          <user-avater :avater="item.avater" :userName="item.userName" />
          <div class="content">
            <div class="name">{{ item.userName }}</div>
            <div class="copy">隶属单位：{{ item.unitName || item.orgName }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getUnitResultDetail, getYearUnitResultDetail } from "@/api/appraisalResults";
import { Toast } from "vant";
export default {
  data() {
    return {
      list: [],
      resultInfo: {}
    };
  },
  created() {
    this.resultInfo = JSON.parse(sessionStorage.getItem("resultInfo"));
    this.init();
  },
  methods: {
    init() {
      if (this.$route.query.is_year == "1") {
        getYearUnitResultDetail({ current: 1, size: 99999, year: this.$route.query.year }).then(res => {
          this.list = res.data.records;
        });
      } else {
        getUnitResultDetail({ year: this.$route.query.year, quarter: this.$route.query.quarter, deptId: this.$route.query.deptId }).then(res => {
          if (res.code == 200) {
            this.list = res.data;
          } else {
            Toast(res.msg);
          }
        });
      }
    }
  }
};
</script>

<style scoped lang="scss">
.card {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: #fff;
  margin-bottom: 12px;
  border-radius: 8px;
  margin: 20px 16px 12px;
  .card-content {
    flex: 1;
    .number-wrap {
      display: flex;
      align-items: center;
      justify-content: space-between;
      line-height: 17px;
      font-size: 12px;
      color: #a3a7ad;
      margin-top: 3px;
      .number {
        color: #f60e36;
      }
    }
    .title {
      font-size: 14px;
      color: #333333;
      line-height: 20px;
    }
  }
}
.list {
  padding-bottom: 8px;
}
.list-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: 16px 12px;
  background: #fff;
  margin: 12px 16px;
  border-radius: 8px;
  .name {
    line-height: 20px;
    color: #333;
    margin-bottom: 3px;
    font-size: 14px;
  }
  .copy {
    font-size: 12px;
    color: #a3a7ad;
    line-height: 17px;
  }
  .user {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-right: 12px;
    background: #2492ff;
    color: #fff;
    text-align: center;
    line-height: 40px;
    font-size: 14px;
  }
}
</style>
